package cn.ejiajunxy.manager.provider;

import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.leo.baseui.mutiType.base.ItemViewProvider;

import cn.ejiajunxy.manager.R;
import cn.ejiajunxy.manager.model.MyOrderModel;


/**
 * Created by zhangguobao on 2018/3/17.
 */
public class MyOrderProvider
        extends ItemViewProvider<MyOrderModel.TradeListBean, MyOrderProvider.ViewHolder> {

    @NonNull
    @Override
    protected ViewHolder onCreateViewHolder(
            @NonNull LayoutInflater inflater, @NonNull ViewGroup parent) {
        View root = inflater.inflate(R.layout.row_my_order, parent, false);
        return new ViewHolder(root);
    }

    @Override
    protected void onBindViewHolder(@NonNull ViewHolder holder, @NonNull MyOrderModel.TradeListBean myOrder) {
        holder.tvPrice.setText((myOrder.amount >= 0 ? "+" : "-") + myOrder.amount + "元");
        holder.tvDate.setText(myOrder.createTime);
        holder.tvTitle.setText(myOrder.title);
    }

    static class ViewHolder extends RecyclerView.ViewHolder {
        TextView tvPrice;
        TextView tvTitle;
        TextView tvDate;

        ViewHolder(View itemView) {
            super(itemView);
            tvPrice = itemView.findViewById(R.id.tvPrice);
            tvTitle = itemView.findViewById(R.id.tvTitle);
            tvDate = itemView.findViewById(R.id.tvDate);
        }
    }
}